package com.drug.mingkang.service.impl;

import com.drug.mingkang.model.ImmRicher;
import com.drug.mingkang.Mapper.ImmRicherMapper;
import com.drug.mingkang.service.ImmRicherService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ImmRicher)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 11:28:44
 */
@Service("immRicherService")
public class ImmRicherServiceImpl implements ImmRicherService {
    @Resource
    private ImmRicherMapper immRicherMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param richerId 主键
     * @return 实例对象
     */
    @Override
    public ImmRicher queryById(String richerId) {
        return this.immRicherMapper.queryById(richerId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<ImmRicher> queryAllByLimit(int offset, int limit) {
        return this.immRicherMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param immRicher 实例对象
     * @return 实例对象
     */
    @Override
    public ImmRicher insert(ImmRicher immRicher) {
        this.immRicherMapper.insert(immRicher);
        return immRicher;
    }

    /**
     * 修改数据
     *
     * @param immRicher 实例对象
     * @return 实例对象
     */
    @Override
    public ImmRicher update(ImmRicher immRicher) {
        this.immRicherMapper.update(immRicher);
        return this.queryById(immRicher.getRicherId());
    }

    /**
     * 通过主键删除数据
     *
     * @param richerId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String richerId) {
        return this.immRicherMapper.deleteById(richerId) > 0;
    }
}